const {
  formatTime
} = require("../../utils/util");

const app = getApp();
Page({

  data: {
    title: "专注记录",
    isTransform: false,
    isBack: true,
    focuslist: [],
    empty: true,
    loading: false,
    min: ''
  },

  getFocusList() {
    let that = this
    wx.cloud.callFunction({
      name: "getOpenid",
      success(res) {
        console.log(res.result.openid);
        wx.cloud.callFunction({
          // 需调用的云函数名
          name: 'getFocusList',
          // 传给云函数的参数
          data: {
            openid: res.result.openid
          },
          success: function (res) {
            console.log(res.result.data);
            let list = res.result.data
            let min = ''
            that.setData({
              loading: true
            })
            if (list.length > 0) {
              for (var i in list) {
                if (list[i].state) {
                  min += list[i].countMinute
                }
              }
              that.setData({
                focuslist: res.result.data,
                empty: true,
                min: min
              })
            } else {
              that.setData({
                focuslist: res.result.data,
                empty: false
              })
            }
          },
          fail: function (err) {
            console.log(err);
          }
        })
      }
    })
  },
  onLoad: function (options) {
    let that = this
    that.getFocusList()
  }
})